# # 无参数
# fn1 = lambda: 50
# print(fn1)
# print(fn1())
# # 一个参数
# fn2 = lambda n: n + 1
# print(fn2(5))
# # 两个参数
# fn3 = lambda a, b: a + b
# print(fn3(4, 3))
# # 带默认参数的
# fn4 = lambda a, b, c=100: a + b + c
# print(fn4(1, 4))
# print(fn4(1, 4, 5))
# # 不定长参数:包裹位置传递
# fn5 = lambda *args: args
# print(fn5("后羿", "男", 6000, "野区"))
# msg = ('后羿', '男', 6000, '野区')
# print(fn5(*msg))
# # 不定长参数:包裹关键字
# fn6 = lambda **kwargs: kwargs
# print(fn6(name="嫦娥", sex="女", age=6000, home="中路"))
# msg = {'name': '嫦娥', 'sex': '女', 'age': 6000, 'home': '中路'}
# print(fn6(**msg))
#
# # a = 1
# # b = 2
# # n = a if a>b else b
# # print(n)
# fn7 = lambda a, b: a if a > b else b
# print(fn7(100, 200))


students = [
    {'name': 'TOM', 'age': 20},
    {'name': 'ROSE', 'age': 19},
    {'name': 'Jack', 'age': 22}
]
# sort排序函数内的形参:key接收一个参数,这个参数需要是个函数,sort会把列表内每个元素传递进这个参数执行,根据执行结果进行排序
students.sort(key=lambda x: x["age"], reverse=True)
print(students)
